<?php
//模型
class LogModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'admin_logs';
	}
	
	function get_list($arr,$page=1,$size=10){
		$where = ' 1 ';
		
		if(isset($arr['module']) && !empty($arr['module'])){
			$where .= " AND module ='{$arr['module']}'";
		}
		if(isset($arr['start_time']) && !empty($arr['start_time']) && isset($arr['end_time']) && !empty($arr['end_time'])){
			$stime = strtotime($arr['start_time']);
			$etime = strtotime($arr['end_time']);
			$where .= " AND addtime >{$stime} AND addtime <={$etime} ";
		}
		if(isset($arr['admin_id']) && !empty($arr['admin_id'])){
			$where .= " AND admin_id ='{$arr['admin_id']}'";
		}
		if(isset($arr['keyword']) && !empty($arr['keyword'])){
			$where .= " AND (msg LIKE '%{$arr['keyword']}%' OR admin_name LIKE '%{$arr['keyword']}%')";
		}
		
		$res = $this->_where_get_list($where,$page,$size,"ORDER BY addtime DESC");
		return $res;
	}
	
	function get_info($id){
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where id='{$id}' limit 1";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
	
	
}

